import { successResp } from '../../core/common'

/**
 * mock文件有两个作用，一是作为和C++桥接的接口定义，二是为支持前后段分离的前端调试
 *
 * API reference
 * https://esti-bd.yuque.com/teid1h/project_doc/ka06lpkxefaygxg9
 */

const EVENT_LIST = Array.from(
  {
    length: 10000,
  },
  (_, key) => ({
    "time": "2023-02-12 07:15:28.002",
    "type": 2001,
    "type_desc": "测量值越限" + key,
    "point_id": "r285:ai:19",
    "point_desc": "水泵开关 （0关闭 1开启）",
    "device_desc": "#4BMS",
    "bay_desc": "#4BMS",
    "station_desc": "郎山储能",
    "value": 15019,
    "desc": "郎山储能  #11BMS #11BMS 最高单体电压越限恢复 值:15019.000"
  }),
);

export const mock = {
  contexts: {
    text: "XX站XX设备",
    id: 'r221:ai:1'
  },
  showTrigger: true,
  signals: {
  },
  slots: {
    request_get_model_node_list: {
      delay: 0,
      response: successResp({
        "model_node_list": [
          {
            "station_id": "sda:lsc",
            "station_desc": "郎山储能",
            "bay_list": [
              {
                "bay_id": 1004,
                "bay_desc": "#1PCS",
                "device_list": [
                  {
                    "device_id": 1800,
                    "device_desc": "#1PCS",
                  }
                ]
              },
              {
                "bay_id": 1005,
                "bay_desc": "#2PCS",
                "device_list": [
                  {
                    "device_id": 1801,
                    "device_desc": "#2PCS",
                  }
                ]
              }
            ]
          }
        ]
      })
    },

    request_get_event_type_list: {
      response: successResp({
        "sort_list": [
          {
            "sort": 1,
            "sort_desc": "系统告警",
            "type_list": [
              {
                "sort": 1,
                "type": 1001,
                "type_desc": "网络告警"
              },
              {
                "sort": 1,
                "type": 1002,
                "type_desc": "主机告警"
              },
              {
                "sort": 1,
                "type": 1003,
                "type_desc": "服务器运行告警"
              }
            ]
          }
        ]
      })
    },

    request_get_event_list: {
      delay: 1000,
      response: (param) => {
        // eslint-disable-next-line no-unused-vars
        const { from, to, type_list, device_list, fuzzy_search, page, rows } = param;

        const start = page * rows;
        const event_list = EVENT_LIST.slice(start, start + rows);
        return successResp({
          total: EVENT_LIST.length,
          total_page: Math.ceil(EVENT_LIST.length / rows),
          page,
          rows,
          event_list,
        });
      }
    },
  }
}